<?php
class DataStaffCompanyInfoAction extends CommonAction {
    
    protected $_str_model           = 'DataStaffCompanyInfo';
    protected $_arr_search          = array(
                                            'staff_id'        => array('IN', '?', 'str'),
                                            'staff_name'      => array('LIKE', '%?%', 'str'),
                                            'bank'            => array('LIKE', '%?%', 'str'),
                                            'bank_account'    => array('LIKE', '%?%', 'str'),
                                            'bank_card'       => array('LIKE', '%?%', 'str'),
                                            'department_id'   => array('IN', '?', 'str'),
                                            'department_name' => array('LIKE', '%?%', 'str'),
                                            'station_id'      => array('IN', '?', 'str'),
                                            'station_name'    => array('LIKE', '%?%', 'str'),
                                            'entry_time'      => array('BETWEEN', '?1,?2', 'str'),
                                            'status'          => array('EQ', '?', 'int'),
                                      );
    protected $_str_status_type     = 'all';
                   
    /**
     * Set params
     * global settings, for index, edit, add
     *
     * @param  void
     * @return void
     * @author andy
     */
    public function set_params() {

        $this->assign('arr_departure_type', $this->get_field_info('departure_type'));
    }
              
    /**
     * Search before
     * 
     * @param  void
     * @return void
     * @author andy
     */
    public function before_search() {

        if ( ! $this->_post('staff_id') ) {
            set_post('staff_id', D('DataStaffBasic')->get_pk_by_name($this->_post('staff_name'), 'staff_name'), false);
        }
        if ( ! $this->_post('department_id') ) {
            set_post('department_id', D('DataCompanyDepartment')->get_pk_by_name($this->_post('department_name'), 'department_name'), false);
        }
        if ( ! $this->_post('station_id') ) {
            set_post('station_id', D('DataCompanyStation')->get_pk_by_name($this->_post('station_name'), 'station_name'), false);
        }
    }
    
    /**
     * Before do action
     * for edit, add
     * 
     * @param  void
     * @return void
     * @author andy
     */
    public function before_do_action() {

        set_post('staff_id', $this->_post('data_staff_basic_staff_id'), false);
        set_post('department_id', $this->_post('data_company_department_department_id'), false);
        set_post('station_id', $this->_post('data_company_station_station_id'), false);
    }
}